package com.youhome.service.model;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.youhome.service.listhub.DetailedCharacteristicsType;
import com.youhome.service.listhub.ListingItemType;
import com.youhome.service.listhub.Schools;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

@Data
public class ListHub {
    private String houseId;

    private String address;

    private String county;

    private String city;

    private String province;

    private String zip;

    private Double listPrice;

    private Double averagePrice;

    private Double listPriceLow;

    private String listingCategory;

    private String listingKey;

    private String listingStatus;

    private Date listingDate;

    private String listingTitle;

    private String providerName;

    private String providerUrl;

    private String providerCategory;

    private String leadRoutingEmail;

    private Integer bedroomCount;

    private Integer bathroomCount;

    private Integer fullBathroomCount;

    private Integer threeQuarterBathroomCount;

    private Integer halfBathroomCount;

    private Integer oneQuarterBathroomCount;

    private String propertyType;

    private String propertySubtype;

    private Boolean permitAddressOnInternet;

    private Boolean permitAddressDisplay;

    private Boolean permitAutomatedValuation;

    private Boolean permitConsumerComment;

    private Boolean permitAddressDisclose;

    private String heroImage;

    private String mlsId;

    private String mlsName;

    private String mlsNumber;

    private Double livingArea;

    private Double lotSize;

    private Integer yearBuilt;

    private String foreclosureStatus;

    private String builderName;

    private Double latitude;

    private Double longitude;

    private String parcelId;
    @JsonIgnore
    private Date modificationTimestamp;

    private String disclaimer;
    @JsonIgnore
    private Date createTime;
    @JsonIgnore
    private Date updateTime;
    @JsonIgnore
    private Boolean enabled;

    private Integer pageView;

    private Integer collection;
    @JsonIgnore
    private Long companyId;
    @JsonIgnore
    private Long counselorId;

    private Boolean isStar;
    @JsonIgnore
    private Boolean isCheck;
    @JsonIgnore
    private String updateBatch;
    @JsonIgnore
    private Integer geocodingStatus;

    @JsonIgnore
    private String geocodingSource;

    @JsonIgnore
    private String dataSource;

    private String listingDescription;

    private DetailedCharacteristicsType characteristics;

    private Schools schools;

    private ListingItemType.Expenses expenses; //额外费用


    //2019-01-17 新增
    private Boolean isNewHouse; //是否是新房
    private String communityName; //社区名称
    private String housesName; //楼盘名称
    private Double forecastRent; //预估租金
    private Double forecastPropertyFee; //预估物业费/年
    private Double forecastHousePropertyTax; //预估房产税


    /**
     * 通过总价除以面积
     *
     * @return 平均价格
     */
    public Double getAveragePrice() {
        if (listPrice != null && listPrice > 0) {
            if (livingArea != null && livingArea > 0) {
                return listPrice / livingArea;
            }
        }
        return averagePrice;
    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    public Date getListingDate() {
        return listingDate;
    }
}